<!--红利曲线剥离-->
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :rules="qryRules">
      <el-row :gutter="12">
        <el-col :span="4">
          <el-form-item label="计算日期">
            <el-date-picker
                v-model="queryParams.refSetDate"
                type="date"
                :style="{width: '100%'}"
                value-format="YYYY-MM-DD"
                @change="handleQuery"
                placeholder="选择日期">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label="红利曲线">
            <el-select v-model="queryParams.divCode" placeholder="红利曲线"
                       size="small"
                       @change="handleQuery"
                       @focus="getCurveCodeList()"
                       filterable="true"
                       :style="{width: '100%'}">
              <el-option
                  v-for="item in curveCodeList"
                  :key="item.code"
                  :label="item.name"
                  :value="item.code"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="1.5">
          <el-form-item>
            <el-button type="primary" icon="Search" v-hasPermi="['curve:divircurve:divircurvestrip:list']"
            size="small" style="margin: 3px 3px" @click="handleQuery">搜索
            </el-button>
          </el-form-item>
        </el-col>
        <el-col :span="1.5">
          <el-button v-if="calTime!=null"
                     type="success"
                     style="margin: 3px 5px"
                     disabled="true"
                     size="small"
          >{{ calTime }}
          </el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            v-hasPermi="['marketdata:DivIrCurve:add']"
            icon="Plus"
            size="small"
            style="margin: 3px 3px"
            type="primary"
            @click="handleAdd"
        >新增
          </el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            v-hasPermi="['marketdata:DivIrCurve:update']"
            style="margin: 3px 3px"
            icon="Edit"
            size="mini"
            :disabled="updateOpen"
            type="primary"
            @click="handleUpdate"
        >修改
          </el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            v-hasPermi="['marketdata:DivirCurve:delete']"
            style="margin: 3px 3px"
            icon="Delete"
            size="mini"
            :disabled="updateOpen"
            type="danger"
            @click="handleDelete"
        >删除
          </el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="warning"
            plain
            icon="Download"
            style="margin: 3px 3px"
            size="small"
            @click="handleImport"
          >导入
          </el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="warning"
            style="margin: 3px 3px"
            icon="Download"
            size="small"
            @click="handleExport"
            v-hasPermi="['curve:divirCurve:divircurvestrip:export']"
        >导出</el-button>
        </el-col>
      </el-row>
    </el-form>
    <!--    <el-row :gutter="10" class="mb8">-->
    <!--      <el-col :span="1.5">-->
    <!--        <el-button-->
    <!--            type="primary"-->
    <!--            plain-->
    <!--            icon="Plus"-->
    <!--            size="small"-->
    <!--            :disabled="btnFlag"-->
    <!--            @click="handleAdd"-->
    <!--            v-hasPermi="['curve:divircurve:divircurvestrip:add']"-->
    <!--        >新增</el-button>-->
    <!--      </el-col>-->
    <!--      <el-col :span="1.5">-->
    <!--        <el-button-->
    <!--            type="success"-->
    <!--            plain-->
    <!--            icon="Edit"-->
    <!--            size="small"-->
    <!--            :disabled="single||btnFlag"-->
    <!--            @click="handleUpdate"-->
    <!--            v-hasPermi="['curve:divircurve:divircurvestrip:edit']"-->
    <!--        >修改</el-button>-->
    <!--      </el-col>-->
    <!--      <el-col :span="1.5">-->
    <!--        <el-button-->
    <!--            type="danger"-->
    <!--            plain-->
    <!--            icon="Delete"-->
    <!--            size="small"-->
    <!--            :disabled="single||btnFlag"-->
    <!--            @click="handleDelete"-->
    <!--            v-hasPermi="['curve:divircurve:divircurvestrip:del']"-->
    <!--        >删除</el-button>-->
    <!--      </el-col>-->
    <!--      <el-col :span="1.5">-->
    <!--        <el-button-->
    <!--            type="info"-->
    <!--            plain-->
    <!--            icon="List"-->
    <!--            :disabled="btnFlag"-->
    <!--            size="small"-->
    <!--            @click="handleCal"-->
    <!--            v-hasPermi="['curve:divircurve:divircurvestrip:cal']"-->
    <!--        >计算</el-button>-->
    <!--      </el-col>-->
    <!--      <el-col :span="1.5">-->
    <!--        <el-button-->
    <!--            type="success"-->
    <!--            plain-->
    <!--            icon="Sort"-->
    <!--            size="small"-->
    <!--            :disabled="btnFlag"-->
    <!--            @click="handleCompare"-->
    <!--            v-hasPermi="['curve:divircurve:divircurvestrip:com']"-->
    <!--        >对比</el-button>-->
    <!--      </el-col>-->
    <!--      <el-col :span="1.5">-->
    <!--        <el-button-->
    <!--            type="warning"-->
    <!--            plain-->
    <!--            icon="Download"-->
    <!--            size="small"-->
    <!--            @click="handleExport"-->
    <!--            v-hasPermi="['marketdata:equity:shares:sharesInfo:export']"-->
    <!--        >当页导出</el-button>-->
    <!--      </el-col>-->
    <!--      <el-col :span="1.5">-->
    <!--        <el-button-->
    <!--            type="warning"-->
    <!--            plain-->
    <!--            v-if="false"-->
    <!--            icon="Download"-->
    <!--            size="small"-->
    <!--            @click="handleExportAll"-->
    <!--            v-hasPermi="['marketdata:equity:shares:sharesInfo:export']"-->
    <!--        >全量导出</el-button>-->
    <!--      </el-col>-->
    <!--      <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>-->
    <!--    </el-row>-->
    <el-row :gutter="10" class="mb8" v-loading="loading">
      <el-col :span="12">
        <xTable ref="divIrcurvestripRef" multiple="false" refId="divIrcurvestripRef" :data="irCrvStripList"
                @selection-change="handleSelectionChange">
          <template #columList>
            <el-table-column label="序号" type="index" width="50">
            </el-table-column>
            <el-table-column label="曲线代码" align="center" prop="divCode" v-if="false" width="150"/>
            <el-table-column label="期限" align="center" prop="divTerm" width="150"/>
            <el-table-column label="日期" align="center" prop="limitDate" width="150"/>
            <el-table-column label="红利率(%)" align="center" prop="divRate" :formatter="formartTablePercentP3"
                             width="120"/>
            <el-table-column label="现货价格" align="center" prop="dpClose" :formatter="formartTableP2" width="120"/>
            <el-table-column label="期货价格" align="center" prop="futureClose" :formatter="formartTableP2" width="120"/>
            <el-table-column label="基差率(%)" align="center" prop="spred" :formatter="formartTablePercentP2"
                             width="120"/>
            <el-table-column label="生效日期" align="center" v-if="false" prop="begDate" width="100"/>
            <el-table-column label="失效日期" align="center" v-if="false" prop="endDate" width="100"/>
          </template>
        </xTable>
      </el-col>
      <el-col :span="12">
        <el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">
          <IrCurveChart ref="lineChartForm" :chartData="lineChartData"/>
        </el-row>
      </el-col>
    </el-row>
    <!-- 添加或修改参数配置对话框 -->
    <el-dialog :title="title" v-model="open" width="30%" :close-on-click-modal="false" append-to-body>
      <el-form ref="divIcvstripRef" :model="form" :rules="rules" label-width="80px" size="small">
        <el-row :gutter="10">
          <el-col :span="24">
            <el-form-item label="红利率曲线" prop="divCode">
              <baseCombox @blur="productSelect" url="/pricing/comboBox/queryDivyield.action" size="small"
                          placeholder="红利率曲线" v-model="form.divCode" :disabled="true"></baseCombox>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="期限" prop="divTerm">
              <el-input v-model="form.divTerm" clearable size="small" maxlength="10"
                        placeholder="请输入期限" :disabled="diableFlag"/>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="利率" prop="divRate">
              <Numberinput v-model="form.divRate" size="small" maxlength="6" precision="3" append="%"/>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="生效日期" prop="currency">
              <el-date-picker
                  v-model="form.begDate" :disabled="diableFlag"
                  type="date"
                  size="small"
                  value-format="YYYY-MM-DD"
                  placeholder="选择生效日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>
    <!--对比曲线弹窗-->
    <!-- 添加或修改参数配置对话框 -->
    <!--    <el-dialog :title="对比曲线" v-model="compareOpen" width="30%" :close-on-click-modal="false" append-to-body>-->
    <!--      <el-form ref="icvstripComRef" :model="compareForm" :rules="compareRules" label-width="80px">-->
    <!--        <el-row :gutter="10">-->
    <!--          <el-col :span="24">-->
    <!--            <el-form-item label="红利曲线" prop="divCode">-->
    <!--              <baseCombox url="/pricing/comboBox/queryIrcurveFilter.action" size="small"-->
    <!--                          placeholder="红利曲线"   v-model="compareForm.divCode"  ></baseCombox>-->
    <!--            </el-form-item>-->
    <!--          </el-col>-->
    <!--          <el-col :span="24">-->
    <!--            <el-form-item label="日期" prop="compareDate">-->
    <!--              <el-date-picker-->
    <!--                  v-model="compareForm.compareDate"-->
    <!--                  type="date"-->
    <!--                  size="small"-->
    <!--                  value-format="YYYY-MM-DD"-->
    <!--                  placeholder="选择日期">-->
    <!--              </el-date-picker>-->
    <!--            </el-form-item>-->
    <!--          </el-col>-->

    <!--        </el-row>-->
    <!--      </el-form>-->
    <!--      <template #footer>-->
    <!--        <div class="dialog-footer">-->
    <!--          <el-button type="primary" @click="submitCompareForm">确 定</el-button>-->
    <!--          <el-button @click="cancelCompare">取 消</el-button>-->
    <!--        </div>-->
    <!--      </template>-->
    <!--    </el-dialog> -->
    <el-dialog :title="upload.title" :close-on-click-modal="false" draggable="true" v-model="upload.open" width="400px"
               append-to-body>
      <el-upload
          ref="uploadRef"
          :limit="1"
          accept=".xlsx, .xls"
          :headers="upload.headers"
          :action="upload.url"
          :disabled="upload.isUploading"
          :on-progress="handleFileUploadProgress"
          :on-success="handleFileSuccess"
          :auto-upload="false"
          drag
      >
        <el-icon class="el-icon--upload">
          <upload-filled/>
        </el-icon>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <template #tip>
          <div class="el-upload__tip text-center">
            <div class="el-upload__tip">
              <el-checkbox v-model="upload.updateSupport"/>
            </div>
            <span>仅允许导入xls、xlsx格式文件。</span>
            <el-link type="primary" :underline="false"
                     v-hasPermi="['marketdata:Curve:download']"
                     style="font-size:12px;vertical-align: baseline;"
                     @click="downTemplate">下载模板
            </el-link>
          </div>
        </template>
      </el-upload>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary"
                     @click="submitFileForm"
                     v-hasPermi="['marketdata:DivIrCurve:import']"
          >确定上传
          </el-button>
          <el-button @click="upload.open = false">取消上传</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="Divircurvestrip">
import lodash from 'lodash';
import {
  getDivIrCrvStripList,
  addDivIrcCurveStrip,
  uptDivIrcCurveStrip,
  delDivIrcCurveStrip,
  getDivIrCrvStripChartData,
  getDivCurveList
} from "@/api/curve/divircurve/divircurvestrip";
import baseCombox from "@/xquant/base/baseCombox";
import Underlyer from '@/xquant/base/underlyer'
import xTable from "@/xquant/base/xTable";
import {getToken} from "@/utils/auth";
import IrCurveChart from "@/views/curve/CurveChart";
const upload = reactive({
  // 是否显示弹出层（用户导入）
  open: false,
  // 弹出层标题（用户导入）
  title: "",
  // 是否禁用上传
  isUploading: false,
  // 设置上传的请求头部
  headers: {Authorization: "Bearer " + getToken()},
  // 上传的地址s
  url: import.meta.env.VITE_APP_BASE_API + "/marketdata/divIrCurveStrip/importDivIrCurve"
});
import {
  formartTablePercentP3,
} from '@/utils/numberUtil'
import Numberinput from '@/xquant/base/number'
const {proxy} = getCurrentInstance();
import moment from 'moment'
import Number from "../../../../xquant/base/number";
import {executeTask} from "../../../../api/pub/pubfunction";
const calTime = ref(null);
const irCrvStripList = ref([]);
const fileName = ref("");
const fileType = ref("");
const open = ref(false);
const rows = ref([]);
const compareOpen = ref(false);
const updateOpen = ref(true);
const loading = ref(false);
const showSearch = ref(true);
const selectObj = ref({});
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");
const opFlag = ref(false);//true时为修改  false为新增
const btnFlag = ref(true);
const curveCodeList = ref([]);
const diableFlag = ref(false);
const router = useRouter();
const data = reactive({
  lineChartData: {},
  form: {},
  compareForm: {},
  queryParams: {
    pageNum: 1,
    divCode: undefined,
    refSetDate: proxy.getSysDate()
  },
  rules: {
    divCode: [{required: true, message: "红利曲线不能为空", trigger: "blur"}],
    divTerm: [{required: true, message: "期限不能为空", trigger: "blur"},{
      pattern: /^[0-9]*[d,D,y,Y,m,M,w,W]$/, message: '格式错误', trigger: 'blur'
    }],
    divRate: [{required: true, message: "红利率不能为空", trigger: "blur"}],
    begDate: [{required: true, message: "生效日期不能为空", trigger: "blur"}],
    endDate: [{required: true, message: "失效日期不能为空", trigger: "blur"}],
  },
  qryRules: {
    divCode: [{required: true, message: "红利曲线不能为空", trigger: "blur"}],
    refSetDate: [{required: true, message: "计算日期不能为空", trigger: "blur"}]
  },
  compareRules: {
    divCode: [{required: true, message: "红利曲线不能为空", trigger: "blur"}],
    compareDate: [{required: true, message: "计算日期不能为空", trigger: "blur"}]
  }
});
const {queryParams, form, rules, lineChartData, compareForm, compareRules, qryRules} = toRefs(data);

function handleImport() {
  if(!canWrite()){
    proxy.$modal.alertError("没有权限导入");
    return;
  }
  upload.open = true;
}

function submitFileForm() {
  proxy.$refs["uploadRef"].submit();
};

const handleFileSuccess = (response, file, fileList) => {
  upload.open = false;
  upload.isUploading = false;
  proxy.$refs["uploadRef"].clearFiles();
  proxy.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", {dangerouslyUseHTMLString: true});
};


const handleFileUploadProgress = (event, file, fileList) => {
  upload.isUploading = true;
};

/** 表单重置 */
function reset() {
  form.value = {
    divCode: undefined,
    ircTerm: undefined,
    ircRate: undefined,
    begDate: proxy.getSysDate(),
    endDate: proxy.getSysDate()
  };
  proxy.resetForm("divIcvstripRef");
}

/** 查询列表 */
function getList() {
  loading.value = true;
  getDivIrCrvStripList(queryParams.value).then(response => {
    irCrvStripList.value = response.rows;
    total.value = response.total;
    loading.value = false;
    //显示曲线
    let divIrCurveRateList = response.rows;
    if(irCrvStripList.value.length>0){
      calTime.value='数据日期: '+irCrvStripList.value[0].begDate;
    }else{
      calTime.value=null;
    }
    let obj = curveCodeList.value.find((item) => {
      return item.code === queryParams.value.divCode;
    });
    proxy.$refs.lineChartForm.setCharData(proxy, '红利曲线', divIrCurveRateList, 'divTerm', 'divRate', queryParams.value.refSetDate + '|' + obj.name, true);

    // getDivIrCrvStripChartData(queryParams.value).then(response => {
    //   let divIrCurveRateList=response.msg;
    //   let obj =curveCodeList.value.find((item)=>{
    //     return item.code === queryParams.value.divCode;
    //   });
    //   proxy.$refs.lineChartForm.setCharData(proxy,'红利曲线',divIrCurveRateList,'divTerm','divRate',queryParams.value.refSetDate+'|'+obj.name,true);
    // })
  });
}


/** 搜索按钮操作 */
function handleQuery() {console.log(queryParams.value.divCode)
  if (lodash.isNull(queryParams.value.refSetDate) || proxy.isVoid(queryParams.value.divCode) || queryParams.value.divCode == '') {
    btnFlag.value = true;
    irCrvStripList.value = [];
    proxy.$refs.lineChartForm.clearCharData();
    total.value = 0;
    return;
  } else {
    btnFlag.value = false;
  }
  queryParams.value.pageNum = 1;
  getList();
}

/** 对比弹窗*/
// function handleCompare(){
//   compareForm.value= {
//     divCode:undefined,
//     compareDate:proxy.getSysDate()
//   };
//   proxy.resetForm("icvstripComRef");
//   compareOpen.value = true;
// }
function getCurveCodeList() {
  getDivCurveList().then(response => {
    curveCodeList.value = response.result;
    if (response.result.length > 0) {
      if (typeof(queryParams.value.divCode) !== "undefined") {

      } else {
        queryParams.value.divCode = response.result[0].code;
      }
      handleQuery();
    }
  });
}

function downTemplate() {
  proxy.download("marketdata/irCurveStrip/downloadFile.action", Object.assign({
    fileName, fileType
  }, {fileName: "红利曲线导入模板.xlsx", fileType: "xls,xlsx", businType: 'DivIrcurve'}), `红利曲线导入模板.xlsx`);
}

onMounted(() => {
  if (proxy.isNotVoid(router.currentRoute.value.query)) {
    queryParams.value.divCode = router.currentRoute.value.query.divCode
  }
  if (proxy.isNotVoid(router.currentRoute.value.query)) {
    queryParams.value.refSetDate = router.currentRoute.value.query.opexDate
  }
  getCurveCodeList();
})
/** 新增按钮操作 */
function handleAdd() {
  if(!canWrite()){
    proxy.$modal.alertError("没有权限新增");
    return;
  }
  reset();
  form.value.divCode = queryParams.value.divCode;
  opFlag.value=false;
  diableFlag.value = false;
  open.value = true;
  title.value = "添加红利率";
}

/** 取消按钮 */
function cancel() {
  open.value = false;
  reset();
}

/** 多选框选中数据 */
function handleSelectionChange(selection) {
  single.value = selection.length != 1;
  if(selection.length == 1) {
    updateOpen.value = false
    rows.value = selection.map((item) => item);
  }
  if(selection.length != 1) {
    updateOpen.value = true
    rows.value = [];
  }
  multiple.value = !selection.length;
}

/** 修改按钮操作 */
function handleUpdate(row) {
  if(!canWrite()){
    proxy.$modal.alertError("没有权限修改");
    return;
  }
  reset();
  title.value = "修改红利率";
  data.form = Object.assign({},rows.value[0]);
  data.form.divRate = data.form.divRate*100
  open.value = true;
  diableFlag.value = true
  opFlag.value = true;
}

/** 提交按钮 */
function submitForm() {
  proxy.$refs["divIcvstripRef"].validate(valid => {
    if (valid) {
      if (opFlag.value == true) {
        open.value = false;
        data.form.divRate = data.form.divRate/100
        uptDivIrcCurveStrip(form.value).then(response => {
          if(response.success){
            proxy.$modal.msgSuccess("修改成功");
            getList();
          }else{
            proxy.$modal.msgWarning(response.msg);
          }

        });
      } else {
        data.form.endDate = '2050-12-31'
        open.value = false;
        data.form.divRate = data.form.divRate/100
        addDivIrcCurveStrip(form.value).then(response => {
          if(response.success){
            proxy.$modal.msgSuccess("新增成功");
            getList();
          }else{
            proxy.$modal.msgWarning(response.msg);
          }

        });
      }
    }
  });
}
/** 新增按钮操作 */
// function handleAdd() {
//   reset();
//   form.value.divCode=queryParams.value.divCode;
//   opFlag.value=false;
//   open.value = true;
//   title.value = "添加曲线定义";
// }
/** 取消按钮 */
// function cancel() {
//   open.value = false;
//   reset();
// }
// function cancelCompare(){
//   compareOpen.value=false;
// }
/** 多选框选中数据 */
// function handleSelectionChange(selection) {
//   selectObj.value = selection.map(item => {
//     return {'divCode':item.divCode,'ircTerm':item.ircTerm,'begDate':item.begDate,'endDate':item.endDate};
//   });
//   single.value = selection.length != 1;
//   multiple.value = !selection.length;
// }
/** 修改按钮操作 */
// function handleUpdate(row) {
//   reset();
//   let param = selectObj.value;
//   if(param.length>0){
//     param=param[0];
//   }
//   getDivIrCrvStripList(param).then(response => {
//     form.value = response.rows[0];
//     open.value = true;
//     opFlag.value=true;
//     title.value = "修改曲线定义";
//   });
// }
/**提交对比曲线*/
// function submitCompareForm(){
//   proxy.$refs["icvstripComRef"].validate(valid => {
//     if (valid) {
//       //显示曲线
//       getDivIrCrvStripChartData({'divCode':compareForm.value.divCode,'refSetDate':compareForm.value.compareDate}).then(response => {
//         let divIrCurveRateList=response.msg;
//         let obj = curveCodeList.value.find((item)=>{
//           return item.code === compareForm.value.divCode;
//         });
//         proxy.$refs.lineChartForm.setCharData(proxy,'红利曲线',divIrCurveRateList,'ircTerm','ircRate',compareForm.value.compareDate+'|'+obj.name,false);
//         compareOpen.value = false;
//       })
//     }
//   });
// }

/** 提交按钮 */
// function submitForm() {
//   proxy.$refs["divIcvstripRef"].validate(valid => {
//     if (valid) {
//       if (opFlag.value==true) {
//         uptIrcCurveStrip(form.value).then(response => {
//           proxy.$modal.msgSuccess("修改成功");
//           open.value = false;
//           getList();
//         });
//       } else {
//         addIrcCurveStrip(form.value).then(response => {
//           proxy.$modal.msgSuccess("新增成功");
//           open.value = false;
//           getList();
//         });
//       }
//     }
//   });
// }
/** 计算按钮操作 */
// function handleCal(row) {
//   const jobContext = '<?xml version="1.0" encoding="gb2312"?>\n' +
//       '<root TYPE="TREE">\n' +
//       '  <Parameter>\n' +
//       '    <BaseDate DATATYPE="STRING" TYPE="SIMPLE" Caption="计算日期">{baseDate}</BaseDate>\n' +
//       '    <Tasks>\n' +
//       '      <Task T_CODE="CALC_TERMSTRUCTURE">\n' +
//       '        <IRCurve>\n' +
//       '          <IsSycCache DATATYPE="INT" Caption="是否同步到缓存" TYPE="SIMPLE" CType="Enum" EnumList="0=否;1=是">1</IsSycCache>\n' +
//       '          <CalcCurveType DATATYPE="INT" Caption="计算代码" TYPE="SIMPLE" CType="Enum" EnumList="0=不计算;1=计算全部;2=计算曲线代码集">2</CalcCurveType>\n' +
//       '          <CurveCodes DATATYPE="STRING" Caption="曲线代码集" TYPE="ARRAY">\n' +
//       '            <V>' + queryParams.value.divCode + '</V>\n' +
//       '          </CurveCodes>\n' +
//       '        </IRCurve>\n' +
//       '      </Task>\n' +
//       '    </Tasks>\n' +
//       '    <TGCode DATATYPE="STRING" TYPE="SIMPLE" Caption="任务分组代码">SystemTask</TGCode>\n' +
//       '  </Parameter>\n' +
//       '</root>';
//   let param =lodash.assign({}, {
//     id: 6,
//     status: '2',
//     type: 'PP_TASK',
//     typeDesc: '计算任务',
//     name: '红利曲线剥离',
//     cronExpression: '0 0/1 * * * ?',
//     executeBegDate: queryParams.value.refSetDate,
//     executeEndDate: queryParams.value.refSetDate,
//     context: jobContext
//   });
//   executeTask(param).then(response => {
//     proxy.$modal.msgSuccess("计算任务已发送");
//     getList();
//     //显示曲线
//     getDivIrCrvStripChartData(queryParams.value).then(response => {
//       let divIrCurveRateList=response.msg;
//       let obj = curveCodeList.value.find((item)=>{
//         return item.code === queryParams.value.divCode;
//       });
//       proxy.$refs.lineChartForm.setCharData(proxy,'红利曲线',divIrCurveRateList,'ircTerm','ircRate',queryParams.value.refSetDate+'|'+obj.name,true);
//     })
//   });
// }

/** 删除按钮操作 */
function handleDelete(row) {
  if(!canWrite()){
    proxy.$modal.alertError("没有权限删除");
    return;
  }
  let param = rows.value[0];
  if(param.length>0){
    param=param[0];
  }
  proxy.$modal.confirm('是否确认删除这条数据？').then(function() {
    return delDivIrcCurveStrip(param);
  }).then(() => {
    getList();
    proxy.$modal.msgSuccess("删除成功");
  }).catch(() => {});
}


/** 导出按钮操作 */
function handleExport() {
  proxy.download("marketdata/divIrCurveStrip/exportDivStrip.action", {
    ...queryParams.value
  }, `红利曲线分析${new Date().getTime()}.xlsx`);
}

function canWrite(){
  let obj = curveCodeList.value.find((item) =>{
    return item.code === queryParams.value.divCode;
  })
  if(obj.divRight === '1'){
    return false;
  }else {
    return true;
  }
}
</script>
